package leetcode;

public class Test1491 {
    public double average(int[] salary) {
        int max=Integer.MIN_VALUE;
        int min=Integer.MAX_VALUE;
        long sum=0;

        for(int i=0;i<salary.length;i++){
            sum+=salary[i];
            if(max<salary[i]){
                max=salary[i];
            }
            if(min>salary[i]){
                min=salary[i];
            }
        }
        //System.out.println(max);
        //System.out.println(min);
        //System.out.println(sum-max-min);
        //System.out.println(salary.length-2);
        return (double)(sum-max-min)/(salary.length-2);
    }
}
